<template>
    <div>
        <el-dialog title="添加规格值" :visible.sync="dialogTableVisible" :close-on-click-modal="false" @close="close">
            <el-form ref="specValue" :model="specValue" label-width="100px" :rules="rules">
                <el-form-item label="规格值名称" prop="value">
                    <el-input v-model="specValue.value" autocomplete="off" placeholder="例:XXX"></el-input>
                </el-form-item>
                <el-form-item label="id" hidden>
                    <el-input v-model="specValue.specId"></el-input>
                </el-form-item>
                <el-form-item label="扩展" prop="extend">
                    <el-input v-model="specValue.extend" autocomplete="off" placeholder="例:XXX"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="dialogTableVisible = false">取 消</el-button>
                <el-button type="primary" @click="insertSpecValue">确 定</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
import http from '@/utils/request';
export default {
    name: 'ThreeInsertSpecValue',

    data() {
        return {
            specValue: {
                specId: ''
            },
            rules: {
                value: [
                { required: true, message: '请输入规格值名称', trigger: 'blur' },
                ],
            },
            dialogTableVisible: false,
            current: ''
        };
    },

    mounted() {
        
    },

    methods: {
        async insertSpecValue(){
            await this.$refs.specValue.validate()
            //console.log(this.id);
            //console.log(this.specValue);
           const s = await http.post('/specValue/insert',this.specValue)
           if(s.data.code>0){
              this.$message({
                            message: '添加成功',
                            type: 'success'
                        })
                        // 关闭模态框
                        this.dialogTableVisible = false
                        // 数据重新加载
                        this.$emit('refresh',this.current)
           }
            this.$refs.specValue.resetFields()
        },
        close(){
            this.$refs.specValue.resetFields()
        }
    },
};
</script>

<style lang="scss" scoped>

</style>